/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qdu.dao;

import com.qdu.util.DatabaseUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 *
 * @author 联想
 */
public class OrderDao {

    private static int SUCCESS = 1;
    private static int ERROR = 2;
    private static int SAME = 3;

// 1.获取图书信息
    public List getOrder(String bookorderform_formnumber) {
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        List list = new ArrayList();
        try {

            con = DatabaseUtil.getConnection();
            ps = con.prepareStatement("select bookinformation.book_name,bookorderform.bookorderform_amount,bookinformation.book_price,bookinformation.book_discountok,bookinformation.book_id from bookinformation,bookorderform where bookinformation.book_id=bookorderform.bookorderform_bookid and bookorderform.bookorderform_formnumber=?");
            ps.setString(1, bookorderform_formnumber);//1代表问号，bookorderform_formnumber代表获取要传的参数
            rs = ps.executeQuery();
            while (rs.next()) {
                List list2 = new ArrayList();
                list2.add(rs.getString(1));
                list2.add(rs.getString(2));
                list2.add(rs.getString(3));
                list2.add(rs.getString(4));
                list2.add(rs.getString(5));
               
                list.add(list2);
            }
          
            return list;
        } catch (Exception e) { 
            e.printStackTrace();
          
            return list;
        } finally { 

            DatabaseUtil.close(rs, ps, con);
        }
    }
//2.获取订单信息
    public List getMyDD(String ordersendingform_userid) {
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        List list = new ArrayList();
        try {
            con = DatabaseUtil.getConnection();
            ps = con.prepareStatement("select ordersendingform_id,ordersendingform_formnumber,ordersendingform_sendok,fangshi from  ordersendingform where ordersendingform_userid=? zhuangtai=? order by ordersendingform_id desc");
            ps.setString(1, ordersendingform_userid);
            ps.setString(2, "正常");
            rs = ps.executeQuery();
            while (rs.next()) {
                List list2 = new ArrayList();
                list2.add(rs.getString(1));
                list2.add(rs.getString(2));
                list2.add(rs.getString(3));
                list2.add(rs.getString(4));
                list.add(list2);

                list.add(list);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            DatabaseUtil.close(rs, ps, con);
        }
        return list;
    }

}

